package lvbu.wang.lvbuoperator.engine;

import android.content.Context;

import lvbu.wang.lvbuoperator.core.App;
import lvbu.wang.lvbuoperator.utils.CommonUtil;


/**
 * Created by DaiQing.Zha on 2016/6/8 0008.
 * Email:1642674371@qq.com
 * Description:服务器访问配置类
 */
public class IotServerConfig {

    /**
     * DEBUG：本地调试环境
     * TEST：测试环境
     * RELEASE：生产环境
     */
    public enum Mode {
        DEBUG, TEST, RELEASE
    }

    private static final String A_ROOT_DEBUG = "http://a.lvbu.co/";
    private static final String A_ROOT_TEST = "";
    private static final String A_ROOT_RELEASE = "http://a.lvbu.wang/";

    private static final String CDN_ROOT_DEBUG = "http://cdn.lvbu.co/";
    private static final String CDN_ROOT_TEST = "";
    private static final String CDN_ROOT_RELEASE = "http://cdn.lvbu.wang/";

    public static Mode USE_SERVER_MODE;
//    static {
//        int APP_VERSION = BaseActivity.getAppVersion(App.getInstance());
//        if (APP_VERSION == ConstantsValue.APP_VERSION_SC) USE_SERVER_MODE = Mode.RELEASE;
//        if (APP_VERSION == ConstantsValue.APP_VERSION_CS) USE_SERVER_MODE = Mode.DEBUG;
//    }

    static {
        final Context context = App.getInstance();
        USE_SERVER_MODE = Enum.valueOf(Mode.class, CommonUtil.getMetaValue(context, "server_mode"));
    }
    public static String getWsServerRoot() {
//        if (USE_SERVER_MODE == Mode.DEBUG) {
//            return A_ROOT_DEBUG;
//        } else if (USE_SERVER_MODE == Mode.TEST) {
//            return A_ROOT_TEST;
//        } else {
//            return A_ROOT_RELEASE;
//        }
        return A_ROOT_RELEASE;
    }
    public static String getCDNServerRoot() {
        if (USE_SERVER_MODE == Mode.DEBUG) {
            return CDN_ROOT_DEBUG;
        } else if (USE_SERVER_MODE == Mode.TEST) {
            return CDN_ROOT_TEST;
        } else {
            return CDN_ROOT_RELEASE;
        }
    }
}
